package com.droid.lib.controls.widget;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.droid.lib.controls.R;

import java.util.ArrayList;
import java.util.List;

public class RadarItemAdapter extends BaseAdapter {
    private List<XRadarView.RedarItem> radarPopItems = new ArrayList<>();
    private Context mContext;

    public RadarItemAdapter(Context mContext) {
        this.mContext = mContext;

    }

    public void setData(List<XRadarView.RedarItem> mlistRedarItems) {
        radarPopItems=mlistRedarItems;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return radarPopItems.size();
    }

    @Override
    public Object getItem(int position) {
        return radarPopItems.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LinearLayout.inflate(mContext, R.layout.radar_item, null);
        TextView circleView = (TextView) view.findViewById(R.id.tv_img);
        TextView name = (TextView) view.findViewById(R.id.tv_name);

        XRadarView.RedarItem item = radarPopItems.get(position);
        circleView.setBackgroundColor(item.getPointColor());
        name.setText(item.getName());
        if(item.isShow()){
            name.setTextColor(Color.BLACK);
        }else{
            name.setTextColor(Color.GRAY);
        }
        return view;
    }
}
